package com.qf.controller;


import com.qf.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/rest")
@ResponseBody
public class MyRestController {

    @GetMapping("/users")
    public List<User> findAll() {
        System.out.println("find  all  users");

        List<User> list = new ArrayList<User>();

        list.add(new User(1, "qqq", "男"));
        list.add(new User(2, "www", "男"));
        return list;
    }

    @GetMapping("/users/{id}")
    public User find(@PathVariable Integer id) {
        User user = new User(1, "www", "女");
        System.out.println("find by id");
        return user;
    }
}
